<%@Page Language="C#"%>
<%@ Import Namespace="System.IO" %>
<script runat=server>

	ArrayList movieList;
	
	protected void Page_Load( object sender, EventArgs e )
	{

		if ( IsPostBack == true )
		{
			movieList = (ArrayList) ViewState["movies"];
		}
		else
		{
			movieList = new ArrayList();
			int i;

			for ( i=0;i<1000;i++)
			{
				movieList.Add( i.ToString() );
			}

			ViewState["movies"] = movieList;
		}

	}
</script>

<h3>Binary Search</h3>

<%
	string somevalue;

	somevalue = (string) Session[0];
	somevalue = (string) Session["fred"];

	int i;
	long start,end;
	int itemIndex;
	ArrayList list = new ArrayList();

	itemIndex = 0;


	// Basic search

	start = Environment.TickCount;

	for( i=0;i<1000;i++)
	{
		itemIndex = movieList.IndexOf("5000");	
	}

	end = Environment.TickCount;

	Response.Write("<P>Search time was " + (end-start).ToString() );

	Response.Write("<P>Index was " + itemIndex.ToString() );
	// Binary Search

	start = Environment.TickCount;

	for( i=0;i<1000;i++)
	{
		itemIndex = movieList.BinarySearch("123");	
	}

	end = Environment.TickCount;

	Response.Write("<P>Search time was " + (end-start).ToString() );




%>


<p style="color:red" id=status EnableViewState=False runat=server />
